package com.cloudcc.mobile.adapter;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

import com.cloudcc.cloudframe.adapter.CommonAdapter;
import com.cloudcc.cloudframe.adapter.ViewHolder;
import com.cloudcc.mobile.R;
import com.cloudcc.mobile.entity.beau.BeauListFilterEntity.SearchView;

public class BeauShiTuAdapter extends
		CommonAdapter<SearchView> {
	private int mSelectPos;

	private OnSelectItemListener mOnSelectItemListener;
	
	public BeauShiTuAdapter(Context mContext) {
		super(mContext);
	}
	@Override
	public void convert(ViewHolder holder,SearchView t) {
		holder.setText(R.id.tv1, t.label);
		ImageView iamge = holder.getView(R.id.iv1);
		if (mSelectPos == holder.getPostion()) {
			iamge.setImageResource(R.drawable.added_item);
		}else{
			iamge.setImageDrawable(new ColorDrawable(Color.WHITE));
		}
		final int pos =holder.getPostion();
		final SearchView tt =t;
		holder.getConvertView().setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				mSelectPos =pos;
				notifyDataSetChanged();
				if (mOnSelectItemListener!=null) {
					mOnSelectItemListener.onSelectItem(pos, tt);
				}
				
			}
		});
	}

	public interface OnSelectItemListener{
		void onSelectItem(int pos,SearchView t);
	}
	
	@Override
	public int getLayoutId() {
		return R.layout.beau_list_filter_childitem;
	}

	public void setSelectItem(int pos) {
		this.mSelectPos = pos;
	}

	public int getSelectPost() {
		return mSelectPos;
	}
	public OnSelectItemListener getmOnSelectItemListener() {
		return mOnSelectItemListener;
	}
	public void setmOnSelectItemListener(OnSelectItemListener mOnSelectItemListener) {
		this.mOnSelectItemListener = mOnSelectItemListener;
	}
	
	
}
